﻿<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="PhotoBrowser.ItemDetailPage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:PhotoBrowser"
    xmlns:common="using:PhotoBrowser.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>

        <!-- TODO: Delete this line if the key AppName is declared in App.xaml -->
        <x:String x:Key="AppName">My Application</x:String>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Style="{StaticResource LayoutRootStyle}" x:Name="LayoutRoot">
    	<Grid.Background>
    		<ImageBrush ImageSource="Assets/AllImages/Bg2.jpg"/>
    	</Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Back button and page title -->
        <ScrollViewer x:Name="scrollViewer" Grid.Row="1" Style="{StaticResource HorizontalScrollViewerStyle}" Margin="0,-20,0,0">
        	<Grid x:Name="grid" Margin="120,0,0,0">
        		<Grid.RowDefinitions>
        			<RowDefinition Height="50"/>
        			<RowDefinition Height="*"/>
        		</Grid.RowDefinitions>
        		<TextBlock x:Name="txtHeading" HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding Title}" VerticalAlignment="Top" FontFamily="Segoe UI" FontSize="32"/>
        		<Grid Grid.Row="1" Height="515" VerticalAlignment="Top">
        			<Grid.ColumnDefinitions>
        				<ColumnDefinition Width="706"/>
        				<ColumnDefinition Width="35"/>
        				<ColumnDefinition Width="450"/>
        				<ColumnDefinition Width="40"/>
        				<ColumnDefinition Width="*"/>
        			</Grid.ColumnDefinitions>
        			<StackPanel Margin="0" Grid.Column="2" Background="#CCDECF91">
        				<TextBlock x:Name="txtItemTitle" HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding Title}" VerticalAlignment="Top" Foreground="Black" FontSize="16" FontFamily="Segoe UI" Margin="15,10,0,0" FontWeight="SemiBold"/>
        				<TextBlock x:Name="txtDetail" HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding Description}" VerticalAlignment="Top" Foreground="Black" FontSize="13.333" FontFamily="Segoe UI" Margin="15,10,15,15" LineStackingStrategy="BlockLineHeight" LineHeight="26.667"/>
        			</StackPanel>
        			<Grid VerticalAlignment="Top">
        				<Grid.RowDefinitions>
        					<RowDefinition Height="*"/>
        					<RowDefinition Height="60"/>

        				</Grid.RowDefinitions>
        				<Image Grid.RowSpan="2" Source="{Binding Image}" Stretch="UniformToFill"/>
        				<Grid Height="60" Margin="0" VerticalAlignment="Top" Grid.Row="1" Background="#7F593711">
                            <TextBlock x:Name="txt" HorizontalAlignment="Right" TextWrapping="Wrap" Text="{Binding Subtitle}" VerticalAlignment="Center" FontSize="12" FontFamily="Segoe UI" Foreground="#B2FFFFFF" Margin="0,0,15,0"/>
        				</Grid>
        				<Image HorizontalAlignment="Center" Height="22" VerticalAlignment="Top" Width="100" Margin="0,-11,0,0" Source="Assets/AllImages/TopBnr.png"/>
        			</Grid>
        		</Grid>
        	</Grid>
        </ScrollViewer>
        <Grid x:Name="grdSnapView" Grid.RowSpan="2" Visibility="Collapsed">
        	<Grid.Background>
        		<ImageBrush ImageSource="Assets/HubPageImages/Bg.jpg"/>
        	</Grid.Background>
        	<TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" Text="&quot;Please switch to full screen to view the details.&quot;" VerticalAlignment="Center" AllowDrop="True" FontSize="21.333" FontFamily="Segoe UI" Foreground="White"/>
        </Grid>
        <Grid>
            <Grid.ColumnDefinitions>
            	<ColumnDefinition Width="Auto"/>
            	<ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
        	<Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
        	<TextBlock x:Name="pageTitle" Grid.Column="1" Text="{Binding Content}" Style="{StaticResource PageHeaderTextStyle}" FontFamily="Sketch Rockwell"/>
        </Grid>

        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="grid">
                        	<DiscreteObjectKeyFrame KeyTime="0">
                        		<DiscreteObjectKeyFrame.Value>
                        			<Thickness>100,0,0,0</Thickness>
                        		</DiscreteObjectKeyFrame.Value>
                        	</DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!-- The back button and title have different styles when snapped -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="grdSnapView">
                        	<DiscreteObjectKeyFrame KeyTime="0">
                        		<DiscreteObjectKeyFrame.Value>
                        			<Visibility>Visible</Visibility>
                        		</DiscreteObjectKeyFrame.Value>
                        	</DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="scrollViewer">
                        	<DiscreteObjectKeyFrame KeyTime="0">
                        		<DiscreteObjectKeyFrame.Value>
                        			<Visibility>Collapsed</Visibility>
                        		</DiscreteObjectKeyFrame.Value>
                        	</DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</common:LayoutAwarePage>
